package com.taysear.bus.util;

import java.util.ArrayList;
import java.util.List;

import com.taysear.bus.AppData;
import com.vaadin.data.validator.RegexpValidator;

public class Constants {
	public static final String elementSeparator = "///";
	public static final String itemValueSeparator = "====";
	
	public static final String COMMON_FIELD_WIDTH_S = "5em";
	public static final String COMMON_FIELD_WIDTH_M = "13em";
	public static final String COMMON_FIELD_WIDTH_L = "20em";
	
	public static final int EMPLOYEE_STATUS_IN_ACTIVE = 2;
	public static final int STATION_STATUS_IN_ACTIVE = 2;
	
	public static final int PARCEL_TABLE_PAGE_LENGTH = 20;
	public static final int LOADINGSHEET_TABLE_PAGE_LENGTH = 10;
	
	public static final int PARCEL_PAYMENT_MODE_ACCOUNT = 2;
	
	public static final int PARCEL_STATUS_NEW = 1;
	public static final int PARCEL_STATUS_EDITED = 2;
	public static final int PARCEL_STATUS_LOADED = 3;
	public static final int PARCEL_STATUS_UNLOADED = 4;
	public static final int PARCEL_STATUS_DELIVERED = 5;
	public static final int PARCEL_STATUS_UNDELIVERED = 6;
	public static final int PARCEL_STATUS_COLLECTED = 7;
	public static final int PARCEL_STATUS_CANCELLED = 8;
	public static final int PARCEL_STATUS_LOCKED = 9;
	public static final int PARCEL_STATUS_UNLOCKED = 10;
	public static final int PARCEL_STATUS_LOST = 11;
	
	public static final int PARCEL_ACTION_CREAT = 1;
	public static final int PARCEL_ACTION_EDIT = 2;
	public static final int PARCEL_ACTION_LOAD = 3;
	public static final int PARCEL_ACTION_UNLOAD = 4;
	public static final int PARCEL_ACTION_DELIVER = 5;
	public static final int PARCEL_ACTION_COLLECT = 6;
	public static final int PARCEL_ACTION_CANCEL = 7;
	public static final int PARCEL_ACTION_LOCK = 8;
	public static final int PARCEL_ACTION_UNLOCK = 9;
	
	public static final int LOADINGSHEET_STATUS_NEW = 1;
	public static final int LOADINGSHEET_STATUS_EDITED = 2;
	public static final int LOADINGSHEET_STATUS_LOADED = 3;
	public static final int LOADINGSHEET_STATUS_DELIVERED = 4;
	public static final int LOADINGSHEET_STATUS_CANCELLED = 5;
	
	public static final int LOADINGSHEET_ACTION_CREAT = 1;
	public static final int LOADINGSHEET_ACTION_EDIT = 2;
	public static final int LOADINGSHEET_ACTION_LOAD = 3;
	public static final int LOADINGSHEET_ACTION_DELIVER = 4;
	public static final int LOADINGSHEET_ACTION_CANCEL = 5;
	
	public static final int BOOKING_STATUS_ACTIVE = 1;
	public static final int BOOKING_STATUS_OPEN = 2;
	public static final int BOOKING_STATUS_RESERVATION = 3;
	public static final int BOOKING_STATUS_USED = 4;
	public static final int BOOKING_STATUS_CANCELLED = 5;
	public static final int BOOKING_STATUS_CHANGED = 6;
	
	public static final int BOOKING_ACTION_BOOK = 1;
	public static final int BOOKING_ACTION_OPEN = 2;
	public static final int BOOKING_ACTION_RESERVE = 3;
	public static final int BOOKING_ACTION_USE = 4;
	public static final int BOOKING_ACTION_CANCEL = 5;
	public static final int BOOKING_ACTION_CHANGE = 6;
	
	public static final int SEAT_STATUS_UNAVAILABLE = 0;
	public static final int SEAT_STATUS_AVAILABLE = 1;
	
	public static final Integer BOOKING_TYPE_RETURN = 1;
	public static final Integer BOOKING_TYPE_ONE_WAY = 2;
	
	public static final Integer PARCEL_PIN_LENGTH = 4;
	public static final Integer PAGE_SIZE = 20;
	
	public static final String[] columnsTimeTable = {"timeId", "reportingTime", "departureTime","ampm"};
	public static final String[] columnsTimeForm = {"reportingTime", "departureTime","ampm"};
	public static final String[] columnsRouteTable = {"routeId", "routeStartName", "routeEndName","routeStatusName"};
	public static final String[] columnsRouteAddForm = {"routeStartId", "routeEndId","routeStatusId"};
	public static final String[] columnsRouteEditForm = {"routeId", "routeStatusId"};
	public static final String[] columnsSeatTable = {"seatId", "description"};
	public static final String[] columnsSeatForm = {"description"};
	public static final String[] columnsBusManifestTable = {"Id", "Origin", "Destination", "Bus", "Driver", "Conductor", "Status", "Time"};
	public static final String[] columnsBusManifestForm = {"description"};
	public static final String[] columnsCollectParcelForm = {"senderName","senderTel", 
		"destination", "destinationSubstation", "receiverName", "receiverTel", "description" };	
	
	public static final String DATE_FORMAT_STRING = "dd/MM/yyyy";
	public static final String DATE_FORMAT_STRING_LONG = "dd/MM/yyyy HH:mm";
	public static final String DATE_FORMAT_STRING_DB = "yyyy-MM-dd HH:mm:ss";
	public static final String DATE_FORMAT_STRING_DB_SHORT = "yyyy-MM-dd";
	
	public static final RegexpValidator telValidator = new RegexpValidator("^25[46]\\d{9}", "Valid tel must be in the follwing format: 254XXXXXXXXX or 256XXXXXXXXX");
	public static final int maxChildAge = Integer.parseInt(AppData.getApp().getProperty("maxChildAge"));

	// message labels
	public static final String ML_AVAILABLE_SEAT_COUNT = "Available seat: ";
	
	// message notifications
	public static final String MN_SUCCESSFULLY_SAVED = "Successfully saved";
	public static final String MN_NO_RESULT = "No result";
	public static final String MN_EMPTY_MENU = "Empty menu";
	
	// message errors
	public static final String ME_FORM_FIELDS_REQUIRED = "Please ensure that all required fields contain valid data.";
	public static final String ME_FORM_DATA = "Error occured while getting form data.";
	public static final String ME_DEPARTURE_ROUTE_EMPTY = "Please select a departure route.";
	public static final String ME_RETURN_ROUTE_EMPTY = "Please select a return route.";
	public static final String ME_FIELDS_REQUIRED = "This field is required";
	public static final String ME_OCCUPIED_SEAT_SELECTED = "The following seat is selected more then one: ";
	public static final String ME_BUSFARE_NOT_FOUND = "No busfare found for the selected substations.";
	public static final String ME_FROM_TO_SUBSTATIONS_ARE_THE_SAME = "From substation and to substation can't be the same.";
	public static final String ME_BETWEEN_2_AND_3_CHARS_ALLOWED = "Allowed is between 2 and 3 characters.";
	
	public enum SysConfig {
		ROUTE(1, "Route"), TIME(2, "Time"), SEAT(3, "Seat"), BUS(4, "Bus");
		
		private Integer id;
		private String description;
		
		SysConfig(Integer id, String description) {
			this.id = id;
			this.description = description;
		}

		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getDescription() {
			return description;
		}
		public void setDescription(String description) {
			this.description = description;
		}
		
		public static List<SysConfig> getList() {
			List<SysConfig> configs = new ArrayList<SysConfig>();
			configs.add(ROUTE);
			configs.add(TIME);
			configs.add(SEAT);
			configs.add(BUS);
			return configs;
		}
	}
}
